<template>
    <div style="padding: 10px;">
        <el-form
                :model="formData"
                ref="queryForm"
                :inline="false"
                :rules="Rules"
                label-width="auto"
                @submit.native.prevent>
            
            <!-- elsename -->
            <el-form-item label="功能名称"
                          desc="功能名称[查询]"
                          prop="name">
                <el-input
                        v-model.trim="formData.name"
                        placeholder="功能名称[查询]"
                        clearable
                        size="small"
                        style="width:220px;"
                />
            </el-form-item>
            
            
            <!-- elsefunUrl -->
            <el-form-item label="功能地址"
                          desc="功能地址"
                          prop="funUrl">
                <el-input
                        v-model.trim="formData.funUrl"
                        placeholder="功能地址[查询]"
                        clearable
                        size="small"
                        style="width:220px;"
                />
            </el-form-item>
            
            
            <el-form-item label="功能分类"
                          desc="功能类型[数据字典=FunType] 1栏目 2功能  3按钮 "
                          prop="funType">
                <dic-select
                        v-model="formData.funType"
                        :code="dicInner.app_fun_funType"
                        placeholder="功能类型[数据字典=FunType] 1栏目 2功能  3按钮 "
                        clearable
                        size="small"
                        style="width:220px;"
                />
            </el-form-item>
            
            
            <el-form-item label="排序号"
                          desc="排序号"
                          prop="orderNum">
                <el-input
                        v-model.trim="formData.orderNum"
                        placeholder="排序号"
                        clearable
                        size="small"
                        style="width:220px;"
                />
            </el-form-item>
            
            
            <!-- elseimg -->
            <el-form-item label="分类图片"
                          desc="分类图片[查询]"
                          prop="img">
                <!--<el-input
                v-model.trim="formData.img"
                placeholder="分类图片[查询]"
                clearable
                size="small"
                style="width:220px;"
                />
                -->
                <el-select v-model="formData.img">
                 <el-option v-for="item in svgIconList" :label="item" :value="item">
                     <svg-icon :icon-class="item"></svg-icon>
                 </el-option>
                </el-select>
            </el-form-item>
            
            
            <!-- elsedeep -->
            <!--           <el-form-item label="功能深度[查询]"
                       desc="功能深度[查询]"
                        prop="deep">
                                         <el-input
                                         v-model.trim="formData.deep"
                                         placeholder="功能深度[查询]"
                                         clearable
                                         size="small"
                                         style="width:220px;"
                                         />
                                   </el-form-item>

            -->
            
            
            <!-- elseparentId -->
            <el-form-item label="上级类别"
                          desc="所属上级类别[关系=SysClass]"
                          prop="parentId">
                <el-input
                        v-model.trim="formData.parentName"
                        :disabled="true"
                        placeholder="所属上级类别"
                        clearable
                        size="small"
                        style="width:220px;"
                />
            </el-form-item>
            
            
            <!-- elsemobileUrl -->
            <!--     <el-form-item label="移动端功能地址"
                 desc="移动端功能地址"
                  prop="mobileUrl">
                                   <el-input
                                   v-model.trim="formData.mobileUrl"
                                   placeholder="移动端功能地址"
                                   clearable
                                   size="small"
                                   style="width:220px;"
                                   />
                             </el-form-item>-->
            
            
            <!-- elsemobileState -->
            <!--        <el-form-item label="移动端应用状态"
                    desc="移动端应用状态"
                     prop="mobileState">
                                      <el-input
                                      v-model.trim="formData.mobileState"
                                      placeholder="移动端应用状态"
                                      clearable
                                      size="small"
                                      style="width:220px;"
                                      />
                                </el-form-item>
-->
            
            
            <!-- <el-form-item label="所属者类型[数据字典=OwnerType]0应用功能1管理员追加功能2用户追加功能"
             desc="所属者类型[数据字典=OwnerType]0应用功能1管理员追加功能2用户追加功能"
              prop="ownerType">
                  <dic-select
                               v-model="formData.ownerType"
                               :code="dicInner.app_fun_ownerType"
                               placeholder="所属者类型[数据字典=OwnerType]0应用功能1管理员追加功能2用户追加功能"
                               clearable
                               size="small"
                               style="width:220px;"
                               />
                         </el-form-item>-->
            
            
            <!--
                        <el-form-item label="功能类型[数据字典=FunType]1内部功能2外部功能"
                        desc="功能类型[数据字典=FunType]1内部功能2外部功能"
                         prop="funScope">
                             <dic-select
                                          v-model="formData.funScope"
                                          :code="dicInner.app_fun_funScope"
                                          placeholder="功能类型[数据字典=FunType]1内部功能2外部功能"
                                          clearable
                                          size="small"
                                          style="width:220px;"
                                          />
                                    </el-form-item>
-->
            
            
            <!-- elseappId -->
            <!--   <el-form-item label="所属应用[关系=AppInfo]"
               desc="所属应用[关系=AppInfo]"
                prop="appId">
                                 <el-input
                                 v-model.trim="formData.appId"
                                 placeholder="所属应用[关系=AppInfo]"
                                 clearable
                                 size="small"
                                 style="width:220px;"
                                 />
                           </el-form-item>-->
            
            
            <!--id -->
        
        
        </el-form>
    
    
    </div>
</template>

<script>
  import { getUrlParam } from '@/utils/index';
  import { alertWithPaylod } from '@/utils/alertUtil';
  import * as  api from '@/apis/appFun.api.js';
  import { default as FormDialog } from '@codegenarate/mydialogplus';
  import { fillData, validatePromise } from '@/utils/index';
  
  
  const Rules = {
    
    'lastEditTime': [{ required: false, message: '最近更新时间', trigger: 'blur' }],
    
    'editUserId': [{ required: false, message: '最近更新人ID', trigger: 'blur' }],
    
    'addTime': [{ required: false, message: '添加时间', trigger: 'blur' }],
    
    'addUser': [{ required: false, message: '添加人', trigger: 'blur' }],
    
    'delState': [{ required: false, message: '有效状态[数据字典=del_state]', trigger: 'blur' }],
    
    'parentIdPath': [{ required: false, message: '所有分类路径', trigger: 'blur' }],
    
    'funUrl': [{ required: true, message: '功能地址[查询]', trigger: 'blur' }],
    
    'serverNumber': [{ required: false, message: '服务器编号ID', trigger: 'blur' }],
    
    'editUser': [{ required: false, message: '最近更新人', trigger: 'blur' }],
    
    'addUserId': [{ required: false, message: '添加人ID', trigger: 'blur' }],
    
    'state': [{ required: false, message: '当前状态[查询]', trigger: 'blur' }],
    
    'orderNum': [{ required: false, message: '排序号', trigger: 'blur' }],
    
    'img': [{ required: false, message: '分类图片[查询]', trigger: 'blur' }],
    
    'deep': [{ required: false, message: '功能深度[查询]', trigger: 'blur' }],
    
    'parentId': [{ required: false, message: '所属上级类别[关系=SysClass]', trigger: 'blur' }],
    
    'mobileUrl': [{ required: false, message: '移动端功能地址', trigger: 'blur' }],
    
    'mobileState': [{ required: false, message: '移动端应用状态', trigger: 'blur' }],
    
    'ownerType': [{ required: false, message: '所属者类型[数据字典=OwnerType]0应用功能1管理员追加功能2用户追加功能', trigger: 'blur' }],
    
    'funScope': [{ required: false, message: '功能类型[数据字典=FunType]1内部功能2外部功能', trigger: 'blur' }],
    
    'funType': [{ required: true, message: '功能类型[数据字典=FunType]', trigger: 'blur' }],
    
    'name': [{ required: true, message: '功能名称[查询]', trigger: 'blur' }],
    
    'appId': [{ required: false, message: '所属应用[关系=AppInfo]', trigger: 'blur' }],
    
    'id': [{ required: false, message: '系统功能信息表[查询]', trigger: 'blur' }],
    
  };
  
  const dicInner = {
    
    '___app_fun_lastEditTime': '最近更新时间',
    'app_fun_lastEditTime': 'app_fun_lastEditTime',
    
    '___app_fun_editUserId': '最近更新人ID',
    'app_fun_editUserId': 'app_fun_editUserId',
    
    '___app_fun_addTime': '添加时间',
    'app_fun_addTime': 'app_fun_addTime',
    
    '___app_fun_addUser': '添加人',
    'app_fun_addUser': 'app_fun_addUser',
    
    '___app_fun_delState': '有效状态[数据字典=del_state] 1有效  5删除',
    'app_fun_delState': 'app_fun_delState',
    
    '___app_fun_parentIdPath': '所有分类路径',
    'app_fun_parentIdPath': 'app_fun_parentIdPath',
    
    '___app_fun_funUrl': '功能地址[查询]',
    'app_fun_funUrl': 'app_fun_funUrl',
    
    '___app_fun_serverNumber': '服务器编号ID',
    'app_fun_serverNumber': 'app_fun_serverNumber',
    
    '___app_fun_editUser': '最近更新人',
    'app_fun_editUser': 'app_fun_editUser',
    
    '___app_fun_addUserId': '添加人ID',
    'app_fun_addUserId': 'app_fun_addUserId',
    
    '___app_fun_state': '当前状态[查询] 1开启  5关闭  ',
    'app_fun_state': 'app_fun_state',
    
    '___app_fun_orderNum': '排序号',
    'app_fun_orderNum': 'app_fun_orderNum',
    
    '___app_fun_img': '分类图片[查询]',
    'app_fun_img': 'app_fun_img',
    
    '___app_fun_deep': '功能深度[查询]',
    'app_fun_deep': 'app_fun_deep',
    
    '___app_fun_parentId': '所属上级类别[关系=SysClass]',
    'app_fun_parentId': 'app_fun_parentId',
    
    '___app_fun_mobileUrl': '移动端功能地址',
    'app_fun_mobileUrl': 'app_fun_mobileUrl',
    
    '___app_fun_mobileState': '移动端应用状态',
    'app_fun_mobileState': 'app_fun_mobileState',
    
    '___app_fun_ownerType': '所属者类型[数据字典=OwnerType]0应用功能1管理员追加功能2用户追加功能',
    'app_fun_ownerType': 'app_fun_ownerType',
    
    '___app_fun_funScope': '功能类型[数据字典=FunType]1内部功能2外部功能',
    'app_fun_funScope': 'app_fun_funScope',
    
    '___app_fun_funType': '功能类型[数据字典=FunType] 1栏目 2功能  3按钮 ',
    'app_fun_funType': 'app_fun_funType',
    
    '___app_fun_name': '功能名称[查询]',
    'app_fun_name': 'app_fun_name',
    
    '___app_fun_appId': '所属应用[关系=AppInfo]',
    'app_fun_appId': 'app_fun_appId',
    
    '___app_fun_id': '系统功能信息表[查询]',
    'app_fun_id': 'app_fun_id',
    
  };
  
  import SvgIcon from '@codegenarate/svg-icon';
  
  export default {
    name: 'appFunModify',
    data() {
      return {
        api: api,
        Rules,
        dicInner,
        formData: {
          
          'lastEditTime': '',
          
          'editUserId': '',
          
          'addTime': '',
          
          'addUser': '',
          
          'delState': '',
          
          'parentIdPath': '',
          
          'funUrl': '',
          
          'serverNumber': '',
          
          'editUser': '',
          
          'addUserId': '',
          
          'state': '',
          
          'orderNum': '',
          
          'img': '',
          
          'deep': '',
          
          'parentId': '',
          parentName: '',
          
          'mobileUrl': '',
          
          'mobileState': '',
          
          'ownerType': '',
          
          'funScope': '',
          
          'funType': '',
          
          'name': '',
          
          'appId': '',
          
          'id': '',
          
        },
        svgIconList: [],
        lists: [],
        selectRows: [],
        classId: '',
        classIdPath: '',
        className: '',
        loading: false,
        isFold: false,
        tableRowClassName({ row, rowIndex }) {
          if (row.rowType == 'total') {
            return 'total-row';
          }
          return '';
        },
      };
    },
    components: {
      SvgIcon,
      dicSelect: () => import('@/components/dicselect.vue'),
      dicTag: () => import('@/components/DicSelect/dic-tag.vue'),
    },
    computed: {},
    watch: {},
    methods: {
      /**
       *  @params _data.
       * @desc 初始化
       */
      initByDialog(_data) {
        fillData(this.formData, _data);
        this.svgIconList= SvgIcon.icon_list;
        console.log('初始化数据', this.formData);
      },
      async submitByDialog(_data) {
        var isyes = await validatePromise.call(this, 'queryForm');
        if (!isyes) {
          return { success: false, message: '请检查必填项' };
        }
        var func = this.formData.id ? api.update : api.add;
        var result = await func(this.formData);
        alertWithPaylod(result);
        return result;
        
      },
      
    },
  };
</script>
